<template>
  <!-- vip定价 -->
  <div class="app-container">
    <div class="fast"></div>
    <div class="boxlaw">
      <ComTable
        @handleStatusChange="changeStatusFn"
        @handleCurrentChange="CurrentPageChangeFn"
        @handleSizeChange="currentPageSizeChangeFn"
        :key="random"
        :list="tableList"
        :modes="tableModes"
        :config="{ border: true, loading }"
        :pagination="{ total: paging.total, pageNum: paging.pageNum }"
      >
        <el-table-column #default="{ row }" align="left">
          <template>
            <el-button
              v-hasPermi="[
                'financial:priceDoc:edit',
                'financial:priceDoc:getInfo',
              ]"
              @click="showEditFn(row)"
              plain
              size="mini"
              type="primary"
              >修改</el-button
            >
          </template>
        </el-table-column>
      </ComTable>
    </div>
    <AddAndEdit
      priceType="价格/次"
      :isImgText="true"
      @EventGetList="editFn"
      ref="AddAndEdit"
      :dialogVisible.sync="dialogVisible"
    ></AddAndEdit>
  </div>
</template>

<script>
import ComForm from "../../../../components/comForm.vue";
import ComSelect from "../../../../components/comSelect.vue";
import ComTable from "../../../../components/comTable.vue";
import comForm from "../../../../components/comForm.vue";
// import { getdocGetTypeApi } from "@/wss/api/ContentSupervision.js";
import {
  getPriceConsultListApi,
  getPriceConsultEditApi,
} from "@/wss/api/financial/pricing/priceConsult.js";
// import { getPriceConsultGetInfoApi } from "@/wss/api/financial/pricing/priceConsult.js";
import AddAndEdit from "./addAndEdit.vue";
export default {
  name: "laws",
  dicts: ["sys_normal_disable"],
  components: { ComSelect, ComForm, comForm, ComTable, AddAndEdit },

  data() {
    return {
      // 是否显示对话框
      dialogVisible: false,
      initSelectValue: "",
      // 加载
      loading: false,
      paging: { pageNum: 1, pageSize: 10, type: "1", total: 10 },
      // 切换筛选状态，不更新bug修复
      random: "",
      // 当前筛选的状态
      currentSelect: "",

      // 表格的数据
      tableList: [],
      tableModes: [
        {
          label: "咨询类目",
          mode: "category",
          options: [
            {
              l: "合同代拟",
              v: 1,
            },
            {
              l: "合同审核",
              v: 2,
            },
          ],
        },
        {
          showOverflowTooltip: true,

          width: 200,
          label: "价格/次（元）",
          mode: "price",
          showOverflowTooltip: true,
        },
        {
          label: "状态",
          mode: "status",
        },
        {
          label: "创建时间",
          mode: "createTime",
          showOverflowTooltip: true,
        },
      ],
    };
  },

  mounted() {
    this.getPriceConsultListFn();
  },
  methods: {
    // 改变函数状态
    async changeStatusFn(row) {
      console.log(row);
      let params = JSON.parse(JSON.stringify(row));
      params.id = params.idStr;

      let { code, msg } = await getPriceConsultEditApi(params);
      // console.log(result);
      if (code == 200) {
        this.$modal.msgSuccess(msg);
        this.getPriceConsultListFn();
      }
    },
    // 当前页发生改变时候
    CurrentPageChangeFn(pageNUm) {
      this.paging.pageNum = pageNUm;
      this.getPriceConsultListFn();
    },
    // 页容量发生改变时候
    currentPageSizeChangeFn(pageSize) {
      this.paging.pageSize = pageSize;
      this.getPriceConsultListFn();
    },
    // // 筛选数据
    // queryFn(arr) {
    //   arr.forEach((item) => {
    //     for (const key in item) {
    //       this.paging[key] = item[key];
    //     }
    //   });
    //   this.currentSelect = this.initSelectValue;
    //   console.log(this.paging, "查询");
    //   this.paging.pageNum = 1;
    //   this.getPriceConsultListFn();
    // },
    // 获取列表数据
    async getPriceConsultListFn() {
      let { rows, code } = await getPriceConsultListApi(this.paging);
      if (code == 200) {
        this.tableList = rows;
      }
      this.loading = false;
      console.log(rows, "质询数据");
    },

    // 打开查看对话框
    async showEditFn(row) {
      this.dialogVisible = true;
      this.$refs.AddAndEdit.getDetailFn(row);
    },
    // 修改函数
    async editFn(data) {
      let { code, msg } = await getPriceConsultEditApi(data);
      if (code == 200) {
        this.$modal.msgSuccess(msg);
        this.getPriceConsultListFn();
      }
    },
  },
};
</script>

<style lang ="scss" scoped>
.fast {
  margin-bottom: 30px;
}
.comform {
  margin-top: 20px;
}
</style>